package kuonjisai.swing;

import java.awt.event.ActionListener;
import java.net.URL;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JToolBar;


public class SwingToolBar extends JToolBar {

	private static SwingMenuActionListener action = null;
	private String imgPath = "/images/toolbar/";
	private String imgExt = ".png";
	
	public SwingToolBar() {
		setFloatable( false );
		action = new SwingMenuActionListener();
		addToolBarButton();			// 툴바에 버튼 추가
		
		
	}
	
	private void addToolBarButton() {
		add( makeToolBarButton("new", "새로만들기"));
		add( makeToolBarButton("close", "닫기"));
		add( makeToolBarButton("exit", "나가기"));
		add( makeToolBarButton("setting", "setting"));
		
	}
	
	private JButton makeToolBarButton( String img, String tooltip) {
		 JButton btn = new JButton();
		 btn.setFocusPainted( false);
		 btn.addActionListener( action );
		 btn.setActionCommand( img );
		 btn.setToolTipText( tooltip );
		 
		 URL iconURL = getClass().getResource( imgPath+ img + imgExt );
		 btn.setIcon( new ImageIcon( iconURL ));
		 
		 return btn;
		 
	}
	
	
}	// SwingToolBar
